<html>
<head><meta charset="utf-8"><title>Inserting statements in a basic block · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Inserting.20statements.20in.20a.20basic.20block.html">Inserting statements in a basic block</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242979207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Inserting%20statements%20in%20a%20basic%20block/near/242979207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Inserting.20statements.20in.20a.20basic.20block.html#242979207">(Jun 17 2021 at 06:51)</a>:</h4>
<p>Could someone point me to a MIR opt pass that needs to insert statements into a basic block? I'm curious whether any special data structures are used for this, since the naive approach of calling <code>Vec::insert</code> is quadratic for a simple pass like turning every statement of a certain kind into two statements</p>



<a name="242979722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Inserting%20statements%20in%20a%20basic%20block/near/242979722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Inserting.20statements.20in.20a.20basic.20block.html#242979722">(Jun 17 2021 at 06:59)</a>:</h4>
<p>Aha: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.BasicBlockData.html#method.expand_statements"><code>BasicBlockData::expand_statements</code></a> is doing something clever with a vector of splice iterators</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>